#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <sstream>
using namespace std;

int main(){
    setlocale(LC_ALL, "ru");
    string path = "/Users/zadoka/Documents/Dev/proga/proga/proga/File.txt";
    
    ifstream fin;
    fin.open(path);
    
    if (!fin.is_open()){
        cout << "error" << endl;
    }else{
        string str;
        string mas[2];
        int i = 0;
        while(!fin.eof()){
            getline(fin, str);
            cout << str << endl;
            mas[i]=str;
            i++;
        }
        
        if((mas[0].substr(0, 7) == "circle(")&&mas[0].back()==char(41)){
            mas[0].erase(0, 7);
            reverse(mas[0].begin(), mas[0].end());
            mas[0].erase(0, 1);
            reverse(mas[0].begin(), mas[0].end());
            
            int check = 0;
            int size = mas[0].size();
            for(int i = 0; i < size; i++){
                if(mas[0][i] == char(32) || mas[0][i] == char(44) || mas[0][i] == char(46) || (mas[0][i] >= char(48) && mas[0][i] <= char(57))){
                    check++;
                }
            }
            
            if(check==size){
                stringstream ss(mas[0]);
                bool flag = false;
                for (int i = 0; mas[0][i] != ',' && mas[0][i] != ' ' && mas[0][i] != '.'; ++i) {
                    if (mas[0][i] >= 57 || mas[0][i] <= 47) {
                        flag = true;
                    }
                }
                if (flag) {
                    return 0;
                }
                
                float num_x, num_y, num_r;
                char comma;
                ss >> num_x >> ws >> num_y >> comma >> num_r;
                if (num_r == 0){
                    stringstream ll(mas[0]);
                    ll >> num_x >> comma >> num_y >> comma >> num_r;
                }
                cout << "x: " << num_x << ", y: " << num_y << ", r: " << num_r << endl;
                cout << "square = " << 3.14 * num_r * num_r << endl;
                cout << "circumference length = " << 3.14 * num_r * 2 << endl;
            }else{
                cout << "ERROR" << endl;
            }
        }else{
            cout << "ERROR" << endl;
        }
    }
    fin.close();
}



